3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next
Many renderers implement scan-conversion and rasterization algorithms by displaying pixels at the borders of lines and polygons either completely on or completely off. This may result in "jaggies," a staircase-like appearance at edges that are not perfectly horizontal or vertical. Such artifacts are visually unpleasant, both in static scenes and in dynamically updated sequences of frames, where they can produce apparent motion across lines or the edges of polygons.
Many renderers support anti-aliasing techniques, which reduce or eliminate this problem. For more complete information about anti-aliasing, consult a book such as Computer Graphics: Principles and Practice by Foley and Van Dam.
QuickDraw 3D provides an anti-alias style to invoke and control anti-aliasing in renderers. Because different renderers support a variety of anti-aliasing algorithms, QuickDraw 3D provides control at an abstract level, with its interpretation left to the renderer. The control structures for anti-alias style are the following:
typedef enum TQ3AntiAliasModeMasks {
kQ3AntiAliasModeMaskEdges = 1 << 0,
kQ3AntiAliasModeMaskFilled = 1 << 1
} TQ3AntiAliasModeMasks;
typedef unsigned long TQ3AntiAliasMode;
typedef struct TQ3AntiAliasStyleData {
TQ3Switch state;
TQ3AntiAliasMode mode;
float quality;
} TQ3AntiAliasStyleData;
You can use the state field, of type TQ3Switch , to turn anti-aliasing on and off. It lets you leave the other state variables set to desired values (either in the data structure or in a style object) and turn anti-aliasing on and off without needing to reinitialize the rest of the state.
You can use the mode field to control which primitives the anti-aliasing techniques affect. If the field is set to kQ3AntiAliasModeMaskEdges , then lines, polylines, and ellipses are anti-aliased, plus all other primitives if you are using an edge fill style. Filled primitives (triangles, NURB surfaces, polyhedra, etc.) are anti-aliased if the mode is set to kQ3AntiAliasModeMaskFilled . Both classes of primitives are anti-aliased if the field is set to kQ3AntiAliasModeMaskEdges | kQ3AntiAliasModeMaskFilled .
Setting the quality field to a value between 0 and 1 provides general control over the level of anti-aliasing. The effect of this value depends on the anti-aliasing algorithm and how the renderer implements it, but in general 0 means a very low level of anti-aliasing and 1 means a very high level. A quality value of 0 does not necessarily mean that anti-aliasing is off, but rather that it is at the lowest level implemented by the renderer.
Routines that help you control anti-aliasing are described in "Managing the Anti-Alias Style" .
Previous | QD3D Book | Overview | Chapter Contents | Next